****************************************************************************************************************
****************************************************************************************************************
****Replication  for "Getting a Seat at the Table: Changes in Military Participation in Government and Coups"***
****************************************************************************************************************
****************************************************************************************************************

clear all

use R&P_replication_data

logit coup_a l.lgdppc chgdppc_l l.war_cow l.acdall lmilexl delta_lmilexl l.ksg_democracy l.gwf_military l.gwf_party l.totcoups coldwar91 c.coup_a_pyrs##c.coup_a_pyrs##c.coup_a_pyrs, cluster(ccode)

predict coup_a_risk if e(sample)

logit coup_s l.lgdppc chgdppc_l l.war_cow l.acdall lmilexl delta_lmilexl l.ksg_democracy l.gwf_military l.gwf_party l.totcoups coldwar91 c.coup_s_pyrs##c.coup_s_pyrs##c.coup_s_pyrs, cluster(ccode)

predict coup_s_risk if e(sample)

*descriptives
sum coup_a_risk if l.gwf_mil_inst==0
sum delta_mil_cab_count if l.gwf_mil_inst==0
sum cab_count_mil_act if l.gwf_mil_inst==0
sum cab_count if l.gwf_mil_inst==0
sum delta_cab_count


*now examine how, changes in MPG affect coup propensity, controlling for coup-risk

logit lead_coup_a delta_mil_cab_count delta_cab_count cab_count_mil_act cab_count coup_a_risk if gwf_mil_inst==0, vce(bootstrap, reps(100) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

logit lead_coup_a i.trich delta_cab_count cab_count_mil_act cab_count coup_a_risk if gwf_mil_inst==0, vce(bootstrap, reps(200) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

****do 200 reps for bootstrapping in following analysis, b/c many of the reps fail, b/c of relative rarity of some of the larger magnitude changes in MPG (in some draws, e.g., no coup attempts for some larger magnitude increases--use 200 reps to get ~100 successful reps

logit lead_coup_a dmcc_increase1 dmcc_increase2 dmcc_increase3_5 dmcc_increases6_onwards dmcc_decrease1 dmcc_decrease2 dmcc_decrease3_5 dmcc_decreases6_onwards delta_cab_count cab_count_mil_act cab_count coup_a_risk if gwf_mil_inst==0, vce(bootstrap, reps(200) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

*marginal effects

logit lead_coup_a i.delta_mil_cab_ordbase0 delta_cab_count cab_count_mil_act cab_count coup_a_risk if gwf_mil_inst==0, vce(bootstrap, reps(200) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

margins, dydx(delta_mil_cab_ordbase0) post

est store marg_effects

#delimit ;
coefplot (marg_effects, label("")   msymbol(O) mlcolor(gs0)       msize(1.5)  mlwidth(.2) mfcolor(gs0)       ciopts(lwidth(*1) lcolor(gs0)) ),
		  scheme(s1mono) 
	 	  ylabel(0(.05).3, labsize(medsmall) angle(horizontal) nogrid)
    	  levels(95)
		  vertical
          xsc(r(1 3.5)) 
          xtitle("Net change in MPG in prior year")
          xlabel(1 `" ->5 "' 2"-3-5" 3"-2" 4"-1" 5`" +1 "' 6"+2" 7"+3-5" 8"+>5")
          ytitle("Effect on probability of a coup attempt") 
		  title("")
		  legend(label(1 "") label(3 "") 
		  region(lcolor(white)) region(lwidth(none) lcolor(none)) cols(2)
		  symy(1.5) si(small) nobox)
		  ;
#delimit cr


***Additional Analyses

*1) coup-proofing controls

logit lead_coup_a delta_mil_cab_count delta_cab_count cab_count_mil_act cab_count coup_a_risk effective eff2 milperl if gwf_mil_inst==0, vce(bootstrap, reps(100) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

logit lead_coup_a i.trich delta_cab_count cab_count_mil_act cab_count coup_a_risk effective eff2 milperl if gwf_mil_inst==0, vce(bootstrap, reps(100) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

logit lead_coup_a dmcc_increase1 dmcc_increase2 dmcc_increase3_5 dmcc_increases6_onwards dmcc_decrease1 dmcc_decrease2 dmcc_decrease3_5 dmcc_decreases6_onwards delta_cab_count cab_count_mil_act cab_count coup_a_risk effective eff2 milperl if gwf_mil_inst==0, vce(bootstrap, reps(200) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))


*2) coup_pyrs

*construct alternative coup risk measure that does not include coup_pyrs

logit coup_a l.lgdppc chgdppc_l l.war_cow l.acdall lmilexl delta_lmilexl l.ksg_democracy l.gwf_military l.gwf_party l.totcoups coldwar91, cluster(ccode)

predict coup_a_risk_nopyrs if e(sample)

*analysis w/new coup risk measures and coup_pyrs polynomial

logit lead_coup_a delta_mil_cab_count delta_cab_count cab_count_mil_act cab_count coup_a_risk_nopyrs f1.c.coup_a_pyrs##f1.c.coup_a_pyrs##f1.c.coup_a_pyrs if gwf_mil_inst==0, vce(bootstrap, reps(100) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

logit lead_coup_a i.trich delta_cab_count cab_count_mil_act cab_count coup_a_risk_nopyrs f1.c.coup_a_pyrs##f1.c.coup_a_pyrs##f1.c.coup_a_pyrs if gwf_mil_inst==0, vce(bootstrap, reps(100) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

logit lead_coup_a dmcc_increase1 dmcc_increase2 dmcc_increase3_5 dmcc_increases6_onwards dmcc_decrease1 dmcc_decrease2 dmcc_decrease3_5 dmcc_decreases6_onwards delta_cab_count cab_count_mil_act cab_count coup_a_risk_nopyrs f1.c.coup_a_pyrs##f1.c.coup_a_pyrs##f1.c.coup_a_pyrs if gwf_mil_inst==0, vce(bootstrap, reps(200) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

*3) coup success risk measure instead of coup attempt risk (coup_a_pyrs included also)
logit lead_coup_a delta_mil_cab_count delta_cab_count cab_count_mil_act cab_count coup_s_risk f1.c.coup_a_pyrs##f1.c.coup_a_pyrs##f1.c.coup_a_pyrs if gwf_mil_inst==0, vce(bootstrap, reps(100) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

logit lead_coup_a i.trich delta_cab_count cab_count_mil_act cab_count coup_s_risk f1.c.coup_a_pyrs##f1.c.coup_a_pyrs##f1.c.coup_a_pyrs if gwf_mil_inst==0, vce(bootstrap, reps(100) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

logit lead_coup_a dmcc_increase1 dmcc_increase2 dmcc_increase3_5 dmcc_increases6_onwards dmcc_decrease1 dmcc_decrease2 dmcc_decrease3_5 dmcc_decreases6_onwards delta_cab_count cab_count_mil_act cab_count coup_s_risk f1.c.coup_a_pyrs##f1.c.coup_a_pyrs##f1.c.coup_a_pyrs if gwf_mil_inst==0, vce(bootstrap, reps(200) seed(033016) cluster(ccode) idcluster(new_ccode) group(ccode))

*4) analysis w/components of coup risk measure rather than coup risk measure

sort ccode year

logit lead_coup_a delta_mil_cab_count delta_cab_count cab_count_mil_act cab_count lgdppc f1.chgdppc_l war_cow acdall f1.lmilexl f1.delta_lmilexl ksg_democracy gwf_military gwf_party totcoups f1.coldwar91 f1.c.coup_a_pyrs##f1.c.coup_a_pyrs##f1.c.coup_a_pyrs if gwf_mil_inst==0, cluster(ccode)

logit lead_coup_a i.trich delta_cab_count cab_count_mil_act cab_count lgdppc f1.chgdppc_l war_cow acdall f1.lmilexl f1.delta_lmilexl ksg_democracy gwf_military gwf_party totcoups f1.coldwar91 f1.c.coup_a_pyrs##f1.c.coup_a_pyrs##f1.c.coup_a_pyrs  if gwf_mil_inst==0, cluster(ccode)

logit lead_coup_a dmcc_increase1 dmcc_increase2 dmcc_increase3_5 dmcc_increases6_onwards dmcc_decrease1 dmcc_decrease2 dmcc_decrease3_5 dmcc_decreases6_onwards delta_cab_count cab_count_mil_act cab_count lgdppc f1.chgdppc_l war_cow acdall f1.lmilexl f1.delta_lmilexl ksg_democracy gwf_military gwf_party totcoups f1.coldwar91 f1.c.coup_a_pyrs##f1.c.coup_a_pyrs##f1.c.coup_a_pyrs  if gwf_mil_inst==0, cluster(ccode)

